Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve frontend startup performance #12936

Merged

Conversation

sdirix
Copy link
Member

@sdirix sdirix commented Sep 25, 2023

The frontend awaits 'initialize', 'configure' and 'onStart' for all frontend contributions. It's therefore very important that no expensive code is run there.

By not awaiting expensive operations in

  • DebugFrontendApplicationContribution.onStart (~300ms)
  • EditorNavigationContribution.onStart (~36-400ms)
  • TerminalFrontendContribution.onStart (~100-300ms)

the reported startup time without using plugins is reduced by ~400-1000ms which is an improvement of ~20-40%.

Contributed on behalf of STMicroelectronics

What it does

It removes some awaited instructions in the critical execution paths which are not really necessary to be awaited. The remaining await instruction in the common-frontend-contribution which takes about ~200ms of time to be executed was not removed as this might have some side effects in theory, although in practice I was not able to observe any.


Note: I also tried to run all initialize, configure and onStart phases each in "parallel", using Promise.all. However when combined with the remaining changes this actually lead to a slowdown, probably because the Javascript thread is already fully utilized.

How to test

Verify that Theia behaves as before. Please have a look at the code paths to see whether something was missed.

You can start Theia with logLevel=debug for more extensive logging and verify the reported startup times. For proper logging in production mode, you need to disable class name substitution. This can be achieved by adding the following to the webpack.config.js:

const TerserPlugin = require('terser-webpack-plugin');
configs[0].optimization = {
    minimizer: [
        new TerserPlugin({
            terserOptions: {
                keep_classnames: true
            }
        })
    ]
};

Review checklist

Reminder for reviewers

@sdirix sdirix changed the title chore: improve frontend startup performance Improve frontend startup performance Sep 25, 2023
@planger planger mentioned this pull request Sep 22, 2023
11 tasks
@JonasHelming
Copy link
Contributor

@kittaakos : Maybe you are interested in reviewing this one?

Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me. I cannot identify any regressions with the approach and the startup time of frontend contributions is indeed reduced.

Though not as much as advertised, but the initial startup time wasn't as long anyway. Reduced the FrontendApplicationContribution#onStart time from ~500ms to ~300ms for me.

@msujew msujew added the performance issues related to performance label Sep 27, 2023
@sdirix
Copy link
Member Author

sdirix commented Sep 27, 2023

I measured the times only on my own machine ;)

@sdirix sdirix force-pushed the frontend-performance-improvements branch from 471a050 to 88d9495 Compare September 27, 2023 12:45
@sdirix
Copy link
Member Author

sdirix commented Sep 27, 2023

I rebased the branch on latest master to solve conflicts in the Changelog. Nothing else changed.

@msujew
Copy link
Member

msujew commented Sep 27, 2023

@sdirix I wasn't fast enough to press the merge button. Please rebase again :)

The frontend awaits 'initialize', 'configure' and 'onStart' for all
frontend contributions. It's therefore very important that no expensive
code is run there.

By not awaiting expensive operations in

 - DebugFrontendApplicationContribution.onStart (~300ms)
 - EditorNavigationContribution.onStart (~36-400ms)
 - TerminalFrontendContribution.onStart (~100-300ms)

the reported startup time without using plugins is reduced by ~400-1000ms
which is an improvement of ~20-40%.

Contributed on behalf of STMicroelectronics
@sdirix sdirix force-pushed the frontend-performance-improvements branch from 88d9495 to 4400ff0 Compare September 27, 2023 14:04
@msujew msujew merged commit 990908b into eclipse-theia:master Sep 27, 2023
11 of 12 checks passed
@vince-fugnitto vince-fugnitto added this to the 1.42.0 milestone Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance issues related to performance
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants